<template>
    <p ref="pName">张三</p>
    <button @click="clickP" >获取子p标签</button>
</template>

<script lang="ts">
export default {
    name: 'Hello'
}
</script>

<!--setup语法糖-->
<script setup lang="ts">
import { ref, defineExpose } from 'vue'

let pName = ref()

function clickP() { 
    console.log(pName.value);
}
//曝光给父亲
defineExpose({ pName })

</script>